package com.example.weblending.domain.statistics;

import com.example.weblending.vo.AnalyzeColumn;
import com.example.weblending.vo.CsvInputColumn;

public class AnnualIncome extends StatisticsBase{

    @Override
    public void init() {
        this.field.add(new StatisticsField("小于10000"));
        this.field.add(new StatisticsField("10000-30000"));
        this.field.add(new StatisticsField("30000-50000"));
        this.field.add(new StatisticsField("50000-80000"));
        this.field.add(new StatisticsField("80000-120000"));
        this.field.add(new StatisticsField("120000-150000"));
        this.field.add(new StatisticsField("150000-200000"));
        this.field.add(new StatisticsField("200000-500000"));
        this.field.add(new StatisticsField("500000+"));
        this.reverse=true;
    }

    @Override
    public void insert(AnalyzeColumn cleanColumn) {
        set(cleanColumn.getAnnualIncome(),cleanColumn.getIs(),cleanColumn);
    }

    @Override
    public void set(int num, float percent, CsvInputColumn column) {
        int index=0;
        if (num>500000){
            this.add(9,percent);
            index=9;
        }
        else if (num>200000){
            this.add(8,percent);
            index=8;
        }
        else if (num>150000){
            this.add(7,percent);
            index=7;
        }
        else if (num>120000){
            this.add(6,percent);
            index=6;
        }
        else if (num>80000){
            this.add(5,percent);
            index=5;
        }
        else if (num>50000){
            this.add(4,percent);
            index=4;
        }
        else if (num>30000){
            this.add(3,percent);
            index=3;
        }
        else if (num>10000){
            this.add(2,percent);
            index=2;
        }
        else{
            this.add(1,percent);
            index=1;
        }
        if(this.reverse){
            index = field.size()-index+1;
        }
        column.setAnnualIncome(index);
    }
}
